﻿@model ViewModelResult
@{
    var _t = Model.Topic;
    var _likes = (List<Like>)Model.OtherList;
    var _class = string.Format("site-block {0} {1}", !_t.IsApproved ? "queue" : string.Empty, _t.IsDeleted ? "deleted" : string.Empty);
    var _id = string.Format("post{0}", _t.TopicId);
}
<div class="white-t" id="@_id">
    <div class="@_class">
        <div class="post-head">
            @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, _t.TopicId), "#" + _t.TopicId, new { @class = "fr" })
            @if (Model.IsMod)
            {
                <input type="checkbox" name="topicId" value="@_t.TopicId" class="selected"/>
            }
            <span class="date-post">
                @ForumContext.PrettyDate(_t.Created)
            </span>
        </div>
        <div class="site-block-content post-content">
            <div class="post-userinfo">
                <div class="p-10">
                    @ForumContext.AvatarRender(_t.Avatar, _t.Sex)
                    <div class="fr-field center bold">
                        @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.USER_INFO, _t.UserName), _t.UserName, new { @class = _t.IsBanned ? "banned" : "" })
                    </div>
                    <div class="fr-field">
                        <dl>
                            <dt>
                                @ForumContext.GetText(LanguageSection.USER_INFO, "GROUP") : </dt>
                            <dd class="@_t.CssClass">
                                @_t.RoleName
                            </dd>
                        </dl>
                    </div>
                    <div class="fr-field">
                        <dl>
                            <dt>
                                @ForumContext.GetText(LanguageSection.USER_INFO, "RegDate"): </dt>
                            <dd>
                                @ForumContext.ShortDateTimeFormat(_t.RegDate)
                            </dd>
                        </dl>
                    </div>
                    <div class="fr-field">
                        <dl>
                            <dt>
                                @ForumContext.GetText(LanguageSection.USER_INFO, "TotalPosts"): </dt>
                            <dd>
                                @_t.TotalPosts
                            </dd>
                        </dl>
                    </div>
                    <div class="fr-field">
                        <dl>
                            <dt>
                                @ForumContext.GetText(LanguageSection.USER_INFO, "TotalVisits"): </dt>
                            <dd>
                                @_t.TotalVisits
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="post-body">
                @if (!string.IsNullOrWhiteSpace(_t.TopicName))
                {
                    <div class="post-title">
                        <h1>
                            @Html.Raw(Html.Encode(_t.TopicName).HighlightKeywords())</h1>
                    </div>
                }
                <div class="post-message">
                    @_t.Message.HtmlClean()
                </div>
                @if (!string.IsNullOrWhiteSpace(_t.Signature))
                {
                    <div class="user-signature after-content">
                        @_t.Signature.HtmlClean()
                    </div>
                }
            </div>
            <br class="empty" />
        </div>
        <div class="site-block-content clear-left">
            <div class="fr">
                @if (_t.ReplyTo == 0)
                {
                    @Html.Link(string.Format("{0}?Id={1}", ForumContext.GetAbsoluteUrl(ForumUrls.NEW_REPLY), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "Reply"), new { @class = "ui-button icon-16 reply" })
                }
                @Html.Link(string.Format("{0}?Id={1}&quote=1", ForumContext.GetAbsoluteUrl(ForumUrls.NEW_REPLY), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "Quote"), new { @class = "ui-button icon-16 quote", title = ForumContext.GetText(LanguageSection.TOPICS, "quote_title") })
                @Html.Link(string.Format("{0}?Id={1}", ForumContext.GetAbsoluteUrl(ForumUrls.NEW_REPLY), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "MultiQuote"), new { @class = "ui-button icon-16 multi-quote", @id = "quote_" + _t.TopicId, @rel = _t.TopicId, @title = ForumContext.GetText(LanguageSection.TOPICS, "Multi_Quote_Title") })
                @if (ForumContext.AllowAccess(CommandType.Edit, null, _t))
                {
                    @Html.Link(string.Format("{0}?Id={1}", ForumContext.GetAbsoluteUrl(ForumUrls.EDIT_POST), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "Edit"), new { @class = "ui-button icon-16 edit" })
                }
                @if (ForumContext.AllowAccess(CommandType.Delete, null, _t))
                {
                    @Html.Link(string.Format("{0}?Id={1}&act={2}", ForumContext.GetAbsoluteUrl(ForumUrls.COMMAND), _t.TopicId, (int)CommandType.Delete), ForumContext.GetText(LanguageSection.TOPICS, "Del"), new { @class = "ui-button icon-16 del confirm {target:'#'}", @title = ForumContext.GetText(LanguageSection.MESSAGES, "DELETE_POSTS_CONFIRM") })
                }
            </div>
            @if (ForumContext.Logined && _likes != null && !_likes.Any(x => x.UserId == ForumContext.UserInfo.UserId))
            {
                @Html.Link(string.Format("{0}?Id={1}", ForumContext.GetAbsoluteUrl(ForumUrls.LIKE_THIS), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "Like"), new { @class = "ui-button icon-16 like {replace:true,target:'#" + _id + "'}" })
            }
            @if (ForumContext.Configuration.AllowGuestReport || (ForumContext.Logined && ForumContext.UserInfo.Permissions.AllowPostReports))
            {

                @Html.Link(string.Format("{0}?Id={1}", ForumContext.GetAbsoluteUrl(ForumUrls.REPORT), _t.TopicId), ForumContext.GetText(LanguageSection.TOPICS, "Report"), new { @class = "ui-button icon-16 report" })
            }
            <br class="empty" />
        </div>
    </div>
    @if (ForumContext.Configuration.AllowShareToSocial && _t.ReplyTo==null && !string.IsNullOrWhiteSpace(ForumContext.Configuration.SocialSharingWidget))
    {
        <div class="site-block white-t sharing-widget">
            <div class="site-block-head">
                @ForumContext.GetMvcText(LanguageSection.TOPICS, "SHARE_POST_TO_SOCIAL_NETWORK")
            </div>
            <div class="site-block-content">
                @Html.Raw(ForumContext.Configuration.SocialSharingWidget)
            </div>
        </div>
    }
    @Html.Partial("Likes", _likes)
</div>
